package com.project_test.kun.travelling_1st.Butler;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.project_test.kun.travelling_1st.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/10/19.
 */
public class ButlerDetailAdapter extends BaseAdapter {
    private Context context;
    private List<Detail.DataBean.IntroListBean> data;

    public ButlerDetailAdapter(Context context, List<Detail.DataBean.IntroListBean> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        Detail.DataBean.IntroListBean introListBean = data.get(0);

        return data!=null?data.size():0;
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder holder=new ViewHolder();
        if (view==null) {
            view= LayoutInflater.from(context).inflate(R.layout.item_detail,viewGroup,false);
            holder.showImg= (ImageView) view.findViewById(R.id.showImg);
            holder.detail= (TextView) view.findViewById(R.id.detail);
            view.setTag(holder);
        }else {
            holder= (ViewHolder) view.getTag();
        }
            Detail.DataBean.IntroListBean introListBean = data.get(i);
            Picasso.with(context).load(introListBean.getPic_url()).into(holder.showImg);
            holder.detail.setText(introListBean.getIntro());
        return view;
    }

    class ViewHolder {
        ImageView showImg;
        TextView detail;
    }

}
